package cn.wgx.common.security.web;

import cn.wgx.common.security.feign.module.sysuser.SysUserFeign;
import cn.wgx.common.security.service.AuthService;
import cn.wgx.common.util.ResponseDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@RestController
@RequestMapping("oauth")
public class AuthCtrl {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    SysUserFeign sysUserFeign;

    @Autowired
    AuthService authService;

    @Value("${apiServer.port:80}")
    private String port;
    @Value("${apiServer.ip:0}")
    private String ip;

    @RequestMapping(value = "/remove/token", method = {RequestMethod.GET, RequestMethod.POST})
    public Map<String, Object> removeToken(@RequestParam String access_token){
        return ResponseDataUtil.returnData(authService.removeToken(access_token));
    }

    @GetMapping(value = "/getPort")
    public Map<String, Object> getPort(@RequestParam String access_token){
        return ResponseDataUtil.returnData(port);
    }

    @GetMapping(value = "/getAddress")
    public Map<String, Object> getAddress(@RequestParam String access_token){
        return ResponseDataUtil.returnData(ip);
    }


//    @GetMapping("/userinfo")
//    public Map getUser(@RequestParam String Username){
//        Map map = new HashMap();
//        LoginAppUser byUsername = userFeign.findByUsername(Username);
//        if(byUsername == null || byUsername.getUser_id() == null){
//            System.out.println("失败通讯");
//        }
//        map.put("code", byUsername);
//        return map;
//    }


}
